<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>PPI example code</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51 General Code Examples
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__ppi__example.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">PPI example code</div>  </div>
<div class="ingroups"><a class="el" href="group__nrf__examples__nrf6310.html">nRF6310 example projects</a></div></div>
<div class="contents">

<p>Example for using PPI module.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ppi__example.html#gaad16890c50156256e260b5205571ddc4">ppi_init</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ppi__example.html#gadd186346e02f7413d2fa6e72fe5f9562">timer0_init</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ppi__example.html#ga43132496bef9b695b89b05793586aa27">timer1_init</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ppi__example.html#ga9459bbd9d6c1f423f968799c09f96434">timer2_init</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ppi__example.html#ga840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Example for using PPI module. </p>
<p>This example uses PPI module for communication between three timer. One timer (T1) is used to generate events every odd seconds, that is at 1,3,5,7 ...etc seconds. This events are used for creating another timer (T0) start task through PPI which is running in counter mode. The other timer (T2) is used to generate events every even seconds that is at 2,4,6,8,..etc and are used to trigger stop task for timer T0 thorough another channel of PPI. Our main program loop is running to trigger the counter every 100 milliseconds. and the timer T0 coutner values are passed to GPIO port. This port can be used to light up LEDs in which case you will see that the LEDs change binary value every 100 milliseconds for a second then PAUSE for one second because of the timer T2 creating an event passed though PPI converting this to timer T0 stop task, in this start event the main loop triggers timer T0 counter increment nothing changes as timer T0 stopped and after one more seconds timer T1 generates event which is passed though PPI to create timer T0 start task and then the LEDS start changing again. This loops goes on for ever.</p>
<div class="fragment"><pre class="fragment">
*  ----------                                        -----------                 ------------------
* |  Timer1  |  CC[0] event at 2,4,6,8,.. seconds   |   PPI     |               |                  |
* |          |-------------------------------------&gt;|   CH0     |--STOP_TASK---&gt;|     Timer0       |
*  ----------                                        -----------                |                  |
*                                                                               |  Counter Mode    |&lt;---Increment every 100ms
*  ----------                                        -----------                |                  |
* |  Timer2  |  CC[0] event at 1,3,5,7,.. seconds   |   PPI     |               |                  |
* |          |-------------------------------------&gt;|   CH1     |--START_TASK--&gt;|                  |
*  ----------                                        -----------                 ------------------
*                                                                                        |
*                                                                                        |
*                                                                                  ---------------
*                                                                                 | capture CC[0] |
*                                                                                  ---------------
*                                                                                        |
*                                                                                      CC[0]
*                                                                                        |
*                                                                                    GPIOs_Output
* </pre></div> <div class="image">
<img src="example_board_setup_a.png" alt="example_board_setup_a.png"/>
<div class="caption">
Use board setup A for this example.</div></div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gaad16890c50156256e260b5205571ddc4"></a><!-- doxytag: member="main.c::ppi_init" ref="gaad16890c50156256e260b5205571ddc4" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static void ppi_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initializes Programmable Peripheral Interconnect peripheral. </p>

<p>Definition at line <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html#l00061">61</a> of file <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="gadd186346e02f7413d2fa6e72fe5f9562"></a><!-- doxytag: member="main.c::timer0_init" ref="gadd186346e02f7413d2fa6e72fe5f9562" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static void timer0_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Timer 0 init which will be started and stopped by timer1 and timer2 using PPI. </p>

<p>Definition at line <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html#l00085">85</a> of file <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga43132496bef9b695b89b05793586aa27"></a><!-- doxytag: member="main.c::timer1_init" ref="ga43132496bef9b695b89b05793586aa27" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static void timer1_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initializes Timer 1 peripheral, creates event and interrupt every 2 seconds, by configuring CC[0] to timer overflow value, we create events at even number of seconds for example, events are created at 2,4,6 .. seconds, this event can be used to stop Timer0 with Timer1-&gt;Event_Compare[0] triggering timer0 TASK_STOP through PPI </p>

<p>Definition at line <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html#l00103">103</a> of file <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga9459bbd9d6c1f423f968799c09f96434"></a><!-- doxytag: member="main.c::timer2_init" ref="ga9459bbd9d6c1f423f968799c09f96434" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static void timer2_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initializes Timer 2 peripheral, creates event and interrupt every 2 seconds, by configuring CC[0] to half of timer overflow value , we create events at odd number of seconds for example, events are created at 1,3,5,... seconds, this event can be used to start Timer0 with Timer2-&gt;Event_Compare[0] triggering timer0 TASK_START through PPI </p>

<p>Definition at line <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html#l00133">133</a> of file <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga840291bc02cba5474a4cb46a9b9566fe"></a><!-- doxytag: member="main.c::main" ref="ga840291bc02cba5474a4cb46a9b9566fe" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>main function </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0. int return type required by ANSI/ISO standard. </dd></dl>

<p>Definition at line <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html#l00162">162</a> of file <a class="el" href="nrf6310_2ppi__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
